package com.zyl.Ecs.common.response;

import lombok.Getter;

/**
 * @version v1.0
 * @ProjectName: Ecs
 * @Package: com.zyl.Ecs.common.response
 * @ClassName: ResultCode
 * @Description TODO (状态码枚举类)
 * @Author 翟玉龙
 * @Date 2024/12/4-11:22
 */
@Getter
public enum ResultCode {

    /* 成功状态码 */
    SUCCESS(200, "操作成功"),
    /* 统一失败状态码 */
    FAILURE(500, "服务器繁忙，请稍后重试"),

    /* 通用错误类型：10001-19999 */
    PARAM_IS_INVALID(10001, "参数无效"),
    PARAM_IS_BLANK(10002, "参数为空"),
    PARAM_TYPE_BIND_ERROR(10003, "参数类型错误"),
    PARAM_NOT_COMPLETE(10004, "参数缺失"),
    DATA_NOT_EXIST(10005, "数据不存在"),
    PERMISSION_NO_ACCESS(10006, "无访问权限"),

    /* 鉴权错误类型：20001-29999 */
    LOGIN_USERNAME_INVALID(20001, "用户名无效"),
    LOGIN_PASSWORD_INVALID(20002, "密码错误"),
    LOGIN_STATUS_INVALID(20003, "账号被禁用，无法登录"),
    TOKEN_BLANK(20004, "Token令牌为空"),
    TOKEN_INVALID(20005, "Token令牌无效"),

    /* 业务异常类型：40001-49999*/
    /* 400xx：用户 */
    ACCOUNT_NOT_EXIST(40001, "用户不存在"),
    ACCOUNT_USERNAME_DUPLICATE(40002, "用户名重复"),
    /* 401xx：角色 */
    ROLE_NOT_EXIST(40101, "角色不存在"),
    ROLE_NAME_DUPLICATE(40102, "角色名重复"),
    /* 402xx：权限 */
    PERMISSION_NOT_EXIST(40201, "权限不存在"),

    /* 410xx：车间 */
    ROOM_NOT_EXIST(41001, "车间不存在"),
    ROOM_NAME_DUPLICATE(41002, "车间名重复"),

    /* 411xx：点位间 */
    POSITION_NOT_EXIST(41101, "点位不存在"),
    POSITION_NAME_DUPLICATE(41102, "点位名重复"),
    POSITION_DELETE_FORBIDDEN(41103, "点位下包含绑定传感器，删除失败，请解绑后重试"),

    /* 412xx：传感器 */
    SENSOR_NOT_EXIST(41101, "传感器不存在"),
    SENSOR_BOUND_FORBIDDEN(41102, "传感器已被绑定，请先解绑"),



    /* 业务错误：30001-39999 */
    BUSINESS_ERROR_POSITION_NAME_DUPLICATE(30001, "点位名称重复"),
    BUSINESS_ERROR_MODE_NAME_DUPLICATE(30002, "模式名称重复"),
    BUSINESS_ERROR_MODE_NOT_EXIST(30003, "模式不存在"),
    BUSINESS_ERROR_ROLE_NAME_DUPLICATE(30004, "角色名称重复"),
    BUSINESS_ERROR_SOME_ROLES_NOT_EXIST(30005, "所选的部分角色不存在"),
    BUSINESS_ERROR_SOME_PERMISSIONS_NOT_EXIST(30006, "所选的部分权限不存在"),
    BUSINESS_ERROR_ROLE_IN_USE_BY_ACCOUNT(30007, "角色正在被某些账户使用，禁止删除"),
    BUSINESS_ERROR_ROLE_IN_USE_BY_PERMISSION(30008, "角色下包含权限，禁止删除"),
    BUSINESS_ERROR_SENSOR_ALREADY_SET_FOR_POSITION(30009, "该传感器已被设置至其他点位！"),
    BUSINESS_ERROR_SCHEME_IN_USE(30010, "配置方案正在被使用中，禁止删除！"),
    ALARM_CONTROL_ERROR(30011, "报警器操作失败！"),
    ALARM_STATUS_CODE_ERROR(30012, "报警器状态码错误！"),
    BUSINESS_ERROR_ROOM_NOT_SELECTED(30013, "未选择所属车间！"),
    THRESHOLD_UPPER_LOWER_EQUAL(30014, "阈值上限与下限不允许相等！");

    private final int code;
    private final String message;

    ResultCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}